package com.adtech.adms;

/**
 * 
 * 
 * @author 李源 
 * @since 2012-7-16 
 * 
 * @Copyright (C) AD Tech Workshop All Right Reserved
 */
public class MemoryMonitor extends Thread{
	private boolean running = true;
	private int index;

	@Override
	public void run() {
		while(running){
			System.out.println("[" + index++ + "]-------------------------------------");
			System.out.println("total:"+Runtime.getRuntime().totalMemory()/(1024) + "K");
			System.out.println("max:"+Runtime.getRuntime().maxMemory()/(1024) + "K");
			System.out.println("free:"+Runtime.getRuntime().freeMemory()/(1024) + "K");

			try {
				Thread.sleep(2 * 100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

	@Override
	public void interrupt(){
		running = false;
	}
}
